;; Test `loop` opcode

(module
  (import "wasi" "print_i32_ln" (func $wasi$print_i32_ln (param i32)))
  (import "wasi" "print_i64_ln" (func $wasi$print_i64_ln (param i64)))
  (memory 1)

  (func $dummy)

  (func $empty (export "empty")
    (loop)
    (loop $l)
  )

  (func $singular (export "singular") (result i32)
    (loop (nop))
    (loop (result i32) (i32.const 7))
  )

  (func $multi (export "multi") (result i32)
    (loop (call $dummy) (call $dummy) (call $dummy) (call $dummy))
    (loop (result i32) (call $dummy) (call $dummy) (i32.const 8) (call $dummy))
    (drop)
    (loop (result i32 i64 i32)
      (call $dummy) (call $dummy) (call $dummy) (i32.const 8) (call $dummy)
      (call $dummy) (call $dummy) (call $dummy) (i64.const 7) (call $dummy)
      (call $dummy) (call $dummy) (call $dummy) (i32.const 9) (call $dummy)
    )
    (drop) (drop)
  )

  (func $nested (export "nested") (result i32)
    (loop (result i32)
      (loop (call $dummy) (block) (nop))
      (loop (result i32) (call $dummy) (i32.const 9))
    )
  )

  (func $deep (export "deep") (result i32)
    (loop (result i32) (block (result i32)
      (loop (result i32) (block (result i32)
        (loop (result i32) (block (result i32)
          (loop (result i32) (block (result i32)
            (loop (result i32) (block (result i32)
              (loop (result i32) (block (result i32)
                (loop (result i32) (block (result i32)
                  (loop (result i32) (block (result i32)
                    (loop (result i32) (block (result i32)
                      (loop (result i32) (block (result i32)
                        (loop (result i32) (block (result i32)
                          (loop (result i32) (block (result i32)
                            (loop (result i32) (block (result i32)
                              (loop (result i32) (block (result i32)
                                (loop (result i32) (block (result i32)
                                  (loop (result i32) (block (result i32)
                                    (loop (result i32) (block (result i32)
                                      (loop (result i32) (block (result i32)
                                        (loop (result i32) (block (result i32)
                                          (loop (result i32) (block (result i32)
                                            (call $dummy) (i32.const 150)
                                          ))
                                        ))
                                      ))
                                    ))
                                  ))
                                ))
                              ))
                            ))
                          ))
                        ))
                      ))
                    ))
                  ))
                ))
              ))
            ))
          ))
        ))
      ))
    ))
  )

  (func $as_select_first (export "as_select_first") (result i32)
    (select (loop (result i32) (i32.const 1)) (i32.const 2) (i32.const 3))
  )
  (func $as_select_mid (export "as_select_mid") (result i32)
    (select (i32.const 2) (loop (result i32) (i32.const 1)) (i32.const 3))
  )
  (func $as_select_last (export "as_select_last") (result i32)
    (select (i32.const 2) (i32.const 3) (loop (result i32) (i32.const 1)))
  )

  (func $as_if_condition (export "as_if_condition")
    (loop (result i32) (i32.const 1)) (if (then (call $dummy)))
  )
  (func $as_if_then (export "as_if_then") (result i32)
    (if (result i32) (i32.const 1) (then (loop (result i32) (i32.const 1))) (else (i32.const 2)))
  )
  (func $as_if_else (export "as_if_else") (result i32)
    (if (result i32) (i32.const 1) (then (i32.const 2)) (else (loop (result i32) (i32.const 1))))
  )

  (func $as_br_if_first (export "as_br_if_first") (result i32)
    (block (result i32) (br_if 0 (loop (result i32) (i32.const 1)) (i32.const 2)))
  )
  (func $as_br_if_last (export "as_br_if_last") (result i32)
    (block (result i32) (br_if 0 (i32.const 2) (loop (result i32) (i32.const 1))))
  )

  (func $as_br_table_first (export "as_br_table_first") (result i32)
    (block (result i32) (loop (result i32) (i32.const 1)) (i32.const 2) (br_table 0 0))
  )
  (func $as_br_table_last (export "as_br_table_last") (result i32)
    (block (result i32) (i32.const 2) (loop (result i32) (i32.const 1)) (br_table 0 0))
  )

  (func $func (param i32 i32) (result i32) (local.get 0))
  (type $check (func (param i32 i32) (result i32)))
  (table funcref (elem $func))
  (func $as_call_indirect_first (export "as_call_indirect_first") (result i32)
    (block (result i32)
      (call_indirect (type $check)
        (loop (result i32) (i32.const 1)) (i32.const 2) (i32.const 0)
      )
    )
  )
  (func $as_call_indirect_mid (export "as_call_indirect_mid") (result i32)
    (block (result i32)
      (call_indirect (type $check)
        (i32.const 2) (loop (result i32) (i32.const 1)) (i32.const 0)
      )
    )
  )
  (func $as_call_indirect_last (export "as_call_indirect_last") (result i32)
    (block (result i32)
      (call_indirect (type $check)
        (i32.const 1) (i32.const 2) (loop (result i32) (i32.const 0))
      )
    )
  )

  (func $as_store_first (export "as_store_first")
    (loop (result i32) (i32.const 1)) (i32.const 1) (i32.store)
  )
  (func $as_store_last (export "as_store_last")
    (i32.const 10) (loop (result i32) (i32.const 1)) (i32.store)
  )

  (func $as_memory_grow_value (export "as_memory_grow_value") (result i32)
    (memory.grow (loop (result i32) (i32.const 1)))
  )

  (func $f (param i32) (result i32) (local.get 0))

  (func $as_call_value (export "as_call_value") (result i32)
    (call $f (loop (result i32) (i32.const 1)))
  )
  (func $as_return_value (export "as_return_value") (result i32)
    (loop (result i32) (i32.const 1)) (return)
  )
  (func $as_drop_operand (export "as_drop_operand")
    (drop (loop (result i32) (i32.const 1)))
  )
  (func $as_br_value (export "as_br_value") (result i32)
    (block (result i32) (br 0 (loop (result i32) (i32.const 1))))
  )
  (func $as_local_set_value (export "as_local_set_value") (result i32)
    (local i32) (local.set 0 (loop (result i32) (i32.const 1))) (local.get 0)
  )
  (func $as_local_tee_value (export "as_local_tee_value") (result i32)
    (local i32) (local.tee 0 (loop (result i32) (i32.const 1)))
  )
  (global $a (mut i32) (i32.const 0))
  (func $as_global_set_value (export "as_global_set_value") (result i32)
    (global.set $a (loop (result i32) (i32.const 1)))
    (global.get $a)
  )
  (func $as_load_operand (export "as_load_operand") (result i32)
    (i32.load (loop (result i32) (i32.const 1)))
  )

 ;; (func $as_unary_operand (export "as_unary_operand") (result i32)
 ;;   (i32.ctz (loop (result i32) (call $dummy) (i32.const 13)))
 ;; )
  (func $as_binary_operand (export "as_binary_operand") (result i32)
    (i32.mul
      (loop (result i32) (call $dummy) (i32.const 3))
      (loop (result i32) (call $dummy) (i32.const 4))
    )
  )
  (func $as_test_operand (export "as_test_operand") (result i32)
    (i32.eqz (loop (result i32) (call $dummy) (i32.const 13)))
  )
  (func $as_compare_operand (export "as_compare_operand") (result i32)
    (f32.gt
      (loop (result f32) (call $dummy) (f32.const 3))
      (loop (result f32) (call $dummy) (f32.const 3))
    )
  )
  (func $as_binary_operands (export "as_binary_operands") (result i32)
    (i32.mul
      (loop (result i32 i32)
        (call $dummy) (i32.const 3) (call $dummy) (i32.const 4)
      )
    )
  )
  (func $as_compare_operands (export "as_compare_operands") (result i32)
    (f32.gt
      (loop (result f32 f32)
        (call $dummy) (f32.const 3) (call $dummy) (f32.const 3)
      )
    )
  )
  (func $as_mixed_operands (export "as_mixed_operands") (result i32)
    (loop (result i32 i32)
      (call $dummy) (i32.const 3) (call $dummy) (i32.const 4)
    )
    (i32.const 5)
    (i32.add)
    (i32.mul)
  )

  (func $break_bare (export "break_bare") (result i32)
    (block (loop (br 1) (br 0) (unreachable)))
    (block (loop (br_if 1 (i32.const 1)) (unreachable)))
    (block (loop (br_table 1 (i32.const 0)) (unreachable)))
    (block (loop (br_table 1 1 1 (i32.const 1)) (unreachable)))
    (i32.const 19)
  )
  (func $break_value (export "break_value") (result i32)
    (block (result i32)
      (i32.const 0)
      (loop (param i32)
        (block (br 2 (i32.const 18)))
        (br 0 (i32.const 20))
      )
      (i32.const 19)
    )
  )
  (func $break_multi_value (export "break_multi_value") (result i32 i32 i64)
    (block (result i32 i32 i64)
      (i32.const 0) (i32.const 0) (i64.const 0)
      (loop (param i32 i32 i64)
        (block (br 2 (i32.const 18) (i32.const -18) (i64.const 18)))
        (br 0 (i32.const 20) (i32.const -20) (i64.const 20))
      )
      (i32.const 19) (i32.const -19) (i64.const 19)
    )
  )
 ;; (func $break_repeated (export "break_repeated") (result i32)
 ;;   (block (result i32)
 ;;     (loop (result i32)
 ;;       (br 1 (i32.const 18))
 ;;       (br 1 (i32.const 19))
 ;;       (drop (br_if 1 (i32.const 20) (i32.const 0)))
 ;;       (drop (br_if 1 (i32.const 20) (i32.const 1)))
 ;;       (br 1 (i32.const 21))
 ;;       (br_table 1 (i32.const 22) (i32.const 0))
 ;;       (br_table 1 1 1 (i32.const 23) (i32.const 1))
 ;;       (i32.const 21)
 ;;     )
 ;;   )
 ;; )

;; (func $break_inner (export "break_inner") (result i32)
;;   (local i32)
;;   (local.set 0 (i32.const 0))
;;   (local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (block (result i32) (br 2 (i32.const 0x1)))))))
;;   (local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (loop (result i32) (br 2 (i32.const 0x2)))))))
;;   (local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (block (result i32) (loop (result i32) (br 1 (i32.const 0x4))))))))
;;   (local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (i32.ctz (br 1 (i32.const 0x8)))))))
;;   (local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (i32.ctz (loop (result i32) (br 2 (i32.const 0x10))))))))
;;   (local.get 0)
;; )
;;
;; (func $cont_inner (export "cont_inner") (result i32)
;;   (local i32)
;;   (local.set 0 (i32.const 0))
;;   (local.set 0 (i32.add (local.get 0) (loop (result i32) (loop (result i32) (br 1)))))
;;   (local.set 0 (i32.add (local.get 0) (loop (result i32) (i32.ctz (br 0)))))
;;   (local.set 0 (i32.add (local.get 0) (loop (result i32) (i32.ctz (loop (result i32) (br 1))))))
;;   (local.get 0)
;; )

  (func $param (export "param") (result i32)
    (i32.const 1)
    (loop (param i32) (result i32)
      (i32.const 2)
      (i32.add)
    )
  )
  (func $params (export "params") (result i32)
    (i32.const 1)
    (i32.const 2)
    (loop (param i32 i32) (result i32)
      (i32.add)
    )
  )
  (func $params_id (export "params_id") (result i32)
    (i32.const 1)
    (i32.const 2)
    (loop (param i32 i32) (result i32 i32))
    (i32.add)
  )
  (func $param_break (export "param_break") (result i32)
    (local $x i32)
    (i32.const 1)
    (loop (param i32) (result i32)
      (i32.const 4)
      (i32.add)
      (local.tee $x)
      (local.get $x)
      (i32.const 10)
      (i32.lt_u)
      (br_if 0)
    )
  )
  (func $params_break (export "params_break") (result i32)
    (local $x i32)
    (i32.const 1)
    (i32.const 2)
    (loop (param i32 i32) (result i32)
      (i32.add)
      (local.tee $x)
      (i32.const 3)
      (local.get $x)
      (i32.const 10)
      (i32.lt_u)
      (br_if 0)
      (drop)
    )
  )
  (func $params_id_break (export "params_id_break") (result i32)
    (local $x i32)
    (local.set $x (i32.const 0))
    (i32.const 1)
    (i32.const 2)
    (loop (param i32 i32) (result i32 i32)
      (local.set $x (i32.add (local.get $x) (i32.const 1)))
      (br_if 0 (i32.lt_u (local.get $x) (i32.const 10)))
    )
    (i32.add)
  )

  (func $effects (export "effects") (result i32)
    (local i32)
    (block
      (loop
        (local.set 0 (i32.const 1))
        (local.set 0 (i32.mul (local.get 0) (i32.const 3)))
        (local.set 0 (i32.sub (local.get 0) (i32.const 5)))
        (local.set 0 (i32.mul (local.get 0) (i32.const 7)))
        (br 1)
        (local.set 0 (i32.mul (local.get 0) (i32.const 100)))
      )
    )
    (i32.eq (local.get 0) (i32.const -14))
  )

  (func $while (export "while") (param i64) (result i64)
    (local i64)
    (local.set 1 (i64.const 1))
    (block
      (loop
        (br_if 1 (i64.eqz (local.get 0)))
        (local.set 1 (i64.mul (local.get 0) (local.get 1)))
        (local.set 0 (i64.sub (local.get 0) (i64.const 1)))
        (br 0)
      )
    )
    (local.get 1)
  )

  (func $for (export "for") (param i64) (result i64)
    (local i64 i64)
    (local.set 1 (i64.const 1))
    (local.set 2 (i64.const 2))
    (block
      (loop
        (br_if 1 (i64.gt_u (local.get 2) (local.get 0)))
        (local.set 1 (i64.mul (local.get 1) (local.get 2)))
        (local.set 2 (i64.add (local.get 2) (i64.const 1)))
        (br 0)
      )
    )
    (local.get 1)
  )

  (func $nesting (export "nesting") (param f32 f32) (result f32)
    (local f32 f32)
    (block
      (loop
        (br_if 1 (f32.eq (local.get 0) (f32.const 0)))
        (local.set 2 (local.get 1))
        (block
          (loop
            (br_if 1 (f32.eq (local.get 2) (f32.const 0)))
            (br_if 3 (f32.lt (local.get 2) (f32.const 0)))
            (local.set 3 (f32.add (local.get 3) (local.get 2)))
            (local.set 2 (f32.sub (local.get 2) (f32.const 2)))
            (br 0)
          )
        )
        (local.set 3 (f32.div (local.get 3) (local.get 0)))
        (local.set 0 (f32.sub (local.get 0) (f32.const 1)))
        (br 0)
      )
    )
    (local.get 3)
  )

  (type $block-sig-1 (func))
  (type $block-sig-2 (func (result i32)))
  (type $block-sig-3 (func (param $x i32)))
  (type $block-sig-4 (func (param i32 f64 i32) (result i32 f64 i32)))

  (func $type_use (export "type_use")
    (loop (type $block-sig-1))
    (loop (type $block-sig-2) (i32.const 0))
    (loop (type $block-sig-3) (drop))
    (i32.const 0) (f64.const 0) (i32.const 0)
    (loop (type $block-sig-4))
    (drop) (drop) (drop)
    (loop (type $block-sig-2) (result i32) (i32.const 0))
    (loop (type $block-sig-3) (param i32) (drop))
    (i32.const 0) (f64.const 0) (i32.const 0)
    (loop (type $block-sig-4)
      (param i32) (param f64 i32) (result i32 f64) (result i32)
    )
    (drop) (drop) (drop)
  )


(func $assert_eq_i32 (param $line i32) (param $x i32) (param $y i32)
       (if (i32.ne (local.get 1) (local.get 2))
           (then
	       (call $wasi$print_i32_ln  (local.get 0))
	       (call $wasi$print_i32_ln  (local.get 1))
	       (call $wasi$print_i32_ln  (local.get 2))
	       (unreachable))
       )
 )

(func $assert_eq_f32 (param $line i32) (param $x f32) (param $y f32)
       (if (f32.ne (local.get 1) (local.get 2))
           (then
	       (call $wasi$print_i32_ln  (local.get 0))
	       (call $wasi$print_i32_ln  (i32.reinterpret_f32 (local.get 1)))
	       (call $wasi$print_i32_ln  (i32.reinterpret_f32 (local.get 2)))
	       (unreachable))
       )
 )

 (func $assert_eq_i64 (param $line i32) (param $x i64) (param $y i64)
       (if (i64.ne (local.get 1) (local.get 2))
           (then
	       (call $wasi$print_i32_ln  (local.get 0))
	       (call $wasi$print_i64_ln  (local.get 1))
	       (call $wasi$print_i64_ln  (local.get 2))
	       (unreachable))
       )
 )

(func $assert_eq_f64 (param $line i32) (param $x f64) (param $y f64)
       (if (f64.ne (local.get 1) (local.get 2))
           (then
	       (call $wasi$print_i32_ln  (local.get 0))
	       (call $wasi$print_i64_ln  (i64.reinterpret_f64 (local.get 1)))
	       (call $wasi$print_i64_ln  (i64.reinterpret_f64 (local.get 2)))
	       (unreachable))
       )
 )

(func $assert_eq_i32_i32_i64 (param $line i32) (param $a i32) (param $b i32) (param $c i64)
        (param $x i32)  (param $y i32)  (param $z i64)
       (call $assert_eq_i32  (local.get 0)   (local.get 1)  (local.get 4))
       (call $assert_eq_i32  (local.get 0)   (local.get 2)  (local.get 5))
       (call $assert_eq_i64  (local.get 0)   (local.get 3)  (local.get 6))
)

 (func $main (export "_start")
(call $empty )
(call $assert_eq_i32 (i32.const 1201) (call $singular ) (i32.const 7))
(call $assert_eq_i32 (i32.const 1301) (call $multi ) (i32.const 8))
(call $assert_eq_i32 (i32.const 1401) (call $nested ) (i32.const 9))
(call $assert_eq_i32 (i32.const 1501) (call $deep ) (i32.const 150))

(call $assert_eq_i32 (i32.const 1601) (call $as_select_first ) (i32.const 1))
(call $assert_eq_i32 (i32.const 1701) (call $as_select_mid ) (i32.const 2))
(call $assert_eq_i32 (i32.const 1801) (call $as_select_last ) (i32.const 2))

(call $as_if_condition )
(call $assert_eq_i32 (i32.const 2001) (call $as_if_then ) (i32.const 1))
(call $assert_eq_i32 (i32.const 2101) (call $as_if_else ) (i32.const 2))

(call $assert_eq_i32 (i32.const 2201) (call $as_br_if_first ) (i32.const 1))
(call $assert_eq_i32 (i32.const 2301) (call $as_br_if_last ) (i32.const 2))

(call $assert_eq_i32 (i32.const 2401) (call $as_br_table_first ) (i32.const 1))
(call $assert_eq_i32 (i32.const 2501) (call $as_br_table_last ) (i32.const 2))

(call $assert_eq_i32 (i32.const 2601) (call $as_call_indirect_first ) (i32.const 1))
(call $assert_eq_i32 (i32.const 2701) (call $as_call_indirect_mid ) (i32.const 2))
(call $assert_eq_i32 (i32.const 2801) (call $as_call_indirect_last ) (i32.const 1))

(call $as_store_first )
(call $as_store_last )

(call $assert_eq_i32 (i32.const 3101) (call $as_memory_grow_value ) (i32.const 1))
(call $assert_eq_i32 (i32.const 3201) (call $as_call_value ) (i32.const 1))
(call $assert_eq_i32 (i32.const 3301) (call $as_return_value ) (i32.const 1))
(call $as_drop_operand )
(call $assert_eq_i32 (i32.const 3501) (call $as_br_value ) (i32.const 1))
(call $assert_eq_i32 (i32.const 3601) (call $as_local_set_value ) (i32.const 1))
(call $assert_eq_i32 (i32.const 3701) (call $as_local_tee_value ) (i32.const 1))
(call $assert_eq_i32 (i32.const 3801) (call $as_global_set_value ) (i32.const 1))
(call $assert_eq_i32 (i32.const 3901) (call $as_load_operand ) (i32.const 1))

;;(call $assert_eq_i32 (i32.const 4001) (call $as_unary_operand ) (i32.const 0))
(call $assert_eq_i32 (i32.const 4101) (call $as_binary_operand ) (i32.const 12))
(call $assert_eq_i32 (i32.const 4201) (call $as_test_operand ) (i32.const 0))
(call $assert_eq_i32 (i32.const 4301) (call $as_compare_operand ) (i32.const 0))
(call $assert_eq_i32 (i32.const 4401) (call $as_binary_operands ) (i32.const 12))
(call $assert_eq_i32 (i32.const 4501) (call $as_compare_operands ) (i32.const 0))
(call $assert_eq_i32 (i32.const 4601) (call $as_mixed_operands ) (i32.const 27))

(call $assert_eq_i32 (i32.const 4701) (call $break_bare ) (i32.const 19))
(call $assert_eq_i32 (i32.const 4801) (call $break_value ) (i32.const 18))

(call $assert_eq_i32_i32_i64 (i32.const 4901) (call $break_multi_value)
  (i32.const 18) (i32.const -18) (i64.const 18))

;;(call $assert_eq_i32 (i32.const 5001) (call $break_repeated ) (i32.const 18))
;; (call $assert_eq_i32 (i32.const 5101) (call $break_inner ) (i32.const 0x1f))

(call $assert_eq_i32 (i32.const 5201) (call $param ) (i32.const 3))
(call $assert_eq_i32 (i32.const 5301) (call $params ) (i32.const 3))
(call $assert_eq_i32 (i32.const 5401) (call $params_id ) (i32.const 3))
(call $assert_eq_i32 (i32.const 5501) (call $param_break ) (i32.const 13))
(call $assert_eq_i32 (i32.const 5601) (call $params_break ) (i32.const 12))
(call $assert_eq_i32 (i32.const 5701) (call $params_id_break ) (i32.const 3))

(call $assert_eq_i32 (i32.const 5801) (call $effects ) (i32.const 1))

(call $assert_eq_i64 (i32.const 5901) (call $while (i64.const 0)) (i64.const 1))
(call $assert_eq_i64 (i32.const 5902) (call $while (i64.const 1)) (i64.const 1))
(call $assert_eq_i64 (i32.const 5903) (call $while (i64.const 2)) (i64.const 2))
(call $assert_eq_i64 (i32.const 5904) (call $while (i64.const 3)) (i64.const 6))
(call $assert_eq_i64 (i32.const 5905) (call $while (i64.const 5)) (i64.const 120))
(call $assert_eq_i64 (i32.const 5906) (call $while (i64.const 20)) (i64.const 2432902008176640000))

(call $assert_eq_i64 (i32.const 6001) (call $for (i64.const 0)) (i64.const 1))
(call $assert_eq_i64 (i32.const 6002) (call $for (i64.const 1)) (i64.const 1))
(call $assert_eq_i64 (i32.const 6003) (call $for (i64.const 2)) (i64.const 2))
(call $assert_eq_i64 (i32.const 6004) (call $for (i64.const 3)) (i64.const 6))
(call $assert_eq_i64 (i32.const 6005) (call $for (i64.const 5)) (i64.const 120))
(call $assert_eq_i64 (i32.const 6006) (call $for (i64.const 20)) (i64.const 2432902008176640000))

(call $assert_eq_f32 (i32.const 6101) (call $nesting (f32.const 0) (f32.const 7)) (f32.const 0))
(call $assert_eq_f32 (i32.const 6102) (call $nesting (f32.const 7) (f32.const 0)) (f32.const 0))
(call $assert_eq_f32 (i32.const 6103) (call $nesting (f32.const 1) (f32.const 1)) (f32.const 1))
(call $assert_eq_f32 (i32.const 6104) (call $nesting (f32.const 1) (f32.const 2)) (f32.const 2))
(call $assert_eq_f32 (i32.const 6105) (call $nesting (f32.const 1) (f32.const 3)) (f32.const 4))
(call $assert_eq_f32 (i32.const 6106) (call $nesting (f32.const 1) (f32.const 4)) (f32.const 6))
(call $assert_eq_f32 (i32.const 6107) (call $nesting (f32.const 1) (f32.const 100)) (f32.const 2550))
(call $assert_eq_f32 (i32.const 6108) (call $nesting (f32.const 1) (f32.const 101)) (f32.const 2601))
(call $assert_eq_f32 (i32.const 6109) (call $nesting (f32.const 2) (f32.const 1)) (f32.const 1))
(call $assert_eq_f32 (i32.const 6110) (call $nesting (f32.const 3) (f32.const 1)) (f32.const 1))
(call $assert_eq_f32 (i32.const 6111) (call $nesting (f32.const 10) (f32.const 1)) (f32.const 1))
(call $assert_eq_f32 (i32.const 6112) (call $nesting (f32.const 2) (f32.const 2)) (f32.const 3))
(call $assert_eq_f32 (i32.const 6113) (call $nesting (f32.const 2) (f32.const 3)) (f32.const 4))
(call $assert_eq_f32 (i32.const 6114) (call $nesting (f32.const 7) (f32.const 4)) (f32.const 10.3095235825))
;; TODO: re-enable and fix for x64
;; (call $assert_eq_f32 (i32.const 6115) (call $nesting (f32.const 7) (f32.const 100)) (f32.const 4381.54785156))
(call $assert_eq_f32 (i32.const 6116) (call $nesting (f32.const 7) (f32.const 101)) (f32.const 2601))

(call $type_use )

(call $wasi$print_i32_ln  (i32.const 666))
)
)
